from manim import *

class AngleTypes(Scene):
    def construct(self):
        # 创建角
        origin = Dot(ORIGIN)
        base_line = Line(ORIGIN, RIGHT * 3, color=BLUE)

        # 锐角（小于90度）
        acute_angle_line = Line(ORIGIN, UP * 2.5 + RIGHT * 1, color=BLUE)
        acute_angle = Angle(base_line, acute_angle_line, radius=0.5, other_angle=False)
        acute_label = Text("锐角 < 90°").next_to(acute_angle, UP + RIGHT)

        # 直角（90度）
        right_angle_line = Line(ORIGIN, UP * 3, color=BLUE)
        right_angle = Angle(base_line, right_angle_line, radius=0.5, other_angle=False)
        right_label = Text("直角 = 90°").next_to(right_angle, UP + RIGHT)

        # 钝角（大于90度小于180度）
        obtuse_angle_line = Line(ORIGIN, UP * 1 + LEFT * 2.5, color=BLUE)
        obtuse_angle = Angle(base_line, obtuse_angle_line, radius=0.5, other_angle=False)
        obtuse_label = Text("钝角 > 90°").next_to(obtuse_angle, UP)

        # 平角（180度）使用旋转动画和圆弧
        straight_angle_line = Line(ORIGIN, RIGHT * 3, color=GREEN)
        straight_angle_arc = Arc(radius=0.5, start_angle=0, angle=PI, color=GREEN)
        straight_label = Text("平角 = 180°").next_to(straight_angle_arc, UP)

        # 反射角（大于180度小于360度）使用旋转动画和圆弧
        reflex_angle_line = Line(ORIGIN, RIGHT * 3, color=ORANGE)
        reflex_angle_arc = Arc(radius=0.5, start_angle=0, angle=3*PI/2, color=ORANGE)
        reflex_label = Text("反射角 > 180°").next_to(reflex_angle_arc, DOWN)

        # 圆周角（360度）使用旋转动画和圆弧
        full_angle_line = Line(ORIGIN, RIGHT * 3, color=RED)
        full_angle_arc = Arc(radius=0.5, start_angle=0, angle=2*PI, color=RED)
        full_label = Text("圆周角 = 360°").next_to(full_angle_arc, DOWN)

        # 添加到场景中
        self.play(Create(origin), Create(base_line))
        self.wait(1)

        # 展示锐角
        self.play(Create(acute_angle_line), Create(acute_angle), Write(acute_label))
        self.wait(2)
        self.play(FadeOut(acute_angle_line), FadeOut(acute_angle), FadeOut(acute_label))

        # 展示直角
        self.play(Create(right_angle_line), Create(right_angle), Write(right_label))
        self.wait(2)
        self.play(FadeOut(right_angle_line), FadeOut(right_angle), FadeOut(right_label))

        # 展示钝角
        self.play(Create(obtuse_angle_line), Create(obtuse_angle), Write(obtuse_label))
        self.wait(2)
        self.play(FadeOut(obtuse_angle_line), FadeOut(obtuse_angle), FadeOut(obtuse_label))

        # 展示平角
        self.play(Create(straight_angle_line))
        self.wait(1)
        self.play(Rotate(straight_angle_line, angle=PI, about_point=ORIGIN), Create(straight_angle_arc), Write(straight_label))
        self.wait(2)
        self.play(FadeOut(straight_angle_line), FadeOut(straight_angle_arc), FadeOut(straight_label))

        # 展示反射角
        self.play(Create(reflex_angle_line))
        self.wait(1)
        self.play(Rotate(reflex_angle_line, angle=3*PI/2, about_point=ORIGIN), Create(reflex_angle_arc), Write(reflex_label))
        self.wait(2)
        self.play(FadeOut(reflex_angle_line), FadeOut(reflex_angle_arc), FadeOut(reflex_label))

        # 展示圆周角
        self.play(Create(full_angle_line))
        self.wait(1)
        self.play(Rotate(full_angle_line, angle=2*PI, about_point=ORIGIN), Create(full_angle_arc), Write(full_label))
        self.wait(2)

if __name__ == "__main__":
    scene = AngleTypes()
    scene.render()